<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
	<title>Login</title>
	<link rel="stylesheet" type="text/css" href="css/style.css" />
	<link rel="stylesheet" type="text/css" href="css/inStyles.css" />
	<link rel="stylesheet" type="text/css" href="./css/layout.css" />
	<script type="text/javascript" src="./jquery/jquery-1.2.6.js" ></script>
	
<style>
	form label {
		margin-left:0;
	}
</style>

<script type="text/javascript">
<%
	String login = (String) request.getAttribute("login");
	if (login != null) {
%>
		parent.window.location.href = 'main.jsp';
<%
	}
%>

	function executar() {
		if (validate()) {
			document.getElementById("acao").value = "login";
			document.getElementById("form").submit();
		}
	}

	function clean() {
		window.location.href = "login.jsp"; 
	}
	
	function validate() {
		if (document.getElementById("login").value == "") {
			alert("Preencha o campo 'Login'!");
			document.getElementById("login").focus();
			return false;
		}
		if (document.getElementById("senha").value == "") {
			alert("Preencha o campo 'Senha'!");
			document.getElementById("senha").focus();
			return false;
		}
		return true;
	}
	
	function changePassword() {
// 		document.getElementById("acao").value = "changePassword";
// 		document.getElementById("form").submit();
	}
	
	$(document).keypress(function(e) {
		  if(e.which == 13) {
			  executar();
		  }
		});
	
</script>
</head>
<body>
	<form name="form" id="form" method="post" action="./dispatcher" autocomplete="off">
		<input type="hidden" name="acao" id="acao" value="">
		<input type="hidden" name="entity" id="entity" value="Usuario"> 
		<input type="hidden" name="id" id="id" value="">

				<div id="main">
					<div id="title">Login</div><br>
					<div id="fields">
						<div id="labels"><label>Login: </label></div>
						<div id="inputs"><input type="text" style="width: 200px;" value="" id="login" name="login"></div>
						<div id="labels"><label>Senha:</label></div>
						<div id="inputs"><input type="password" style="width: 200px;" value="" id="senha" name="senha"></div>
<!-- 						<div id="linkSenha"> <a href="javascript:changePassword();">Esqueci minha senha</a></div> -->
					</div>
					<div id="buttons" style="width: 100%; margin-right: 400px; padding-top:15px;">
						<input class="small button purple" type="button" value="Entrar" onclick="executar();"> 
						<input class="small button purple" type="button" value="Limpar" onclick="clean()">
					</div>
				</div>
	</form>
</body>
</html>

<%@ include file="../message.jsp"%>